home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / swags-z / sorting.swg / 0004_BUBBLE1.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  655b  |  31 lines

  1. {
  2. > Does anyone know of a routine or code that would allow For a
  3. > alphabetical sort?
  4.  
  5. Depends on what Type of sorting you want to do- For a very small list, a
  6. simple BubbleSort will suffice.
  7. }
  8. Const
  9.   max = 50;
  10. Var
  11.   i,j:Integer;
  12.   a : Array[1..max] of String;
  13.   temp : String;
  14. begin
  15.   For i := 1 to 50 do
  16.     For j := 1 to 50 do
  17.       if a[i] < a[j] then
  18.       begin
  19.         temp := a[i];
  20.         a[i] := a[j];
  21.         a[j] := temp;
  22.       end;  { if }
  23. end.
  24.  
  25. {
  26. If it's a bigger list than, say 100 or so elements, or it needs to be
  27. sorted often, you'll probably need a better algorithm, like a shell sort
  28. or a quicksort.
  29. }
  30.  
  31.